Uec3.ModifyPasswordWindow = Ext.extend(Ext.app.Module, {
	id : 'modifyPassword',
	type : 'common/modifyPassword',

	init : function(initParams) {},

	getComponents : function(rowIndex) {

		var changePasswordForm;
		var changePassword_ajax;

		var componentChangePasswordInits = function() {

			Ext.apply(Ext.form.VTypes, {
						password : function(val, field) {
							if (field.initialPassField) {var pwd = Ext.getCmp(field.initialPassField);return (val == pwd.getValue());}
							return true;
						},
						passwordText : '密码不匹配'
					});

			changePassword_ajax = new Ext.data.Connection();

			changePasswordForm = new Ext.form.FormPanel({
						labelAlign : 'right',
						frame : true,
						labelWidth : 88,
						loadingText : '加载数据中...',
						bodyStyle : 'padding:40px 20px 0 0',
						buttonAlign : 'center',
						height:300,
						url : '',
						defaults : {width : 200,height:25,inputType : 'password',style : "margin-top:8px",labelStyle:"margin-top:8px"},
						defaultType : 'textfield',
						items : [
						          {fieldLabel : '旧密码',name : 'superPassword',allowBlank : false,minLength : 6,minLengthText : "密码的长度不小于6位"},
						          {fieldLabel : '新密码',name : 'password',id : 'password',minLengthText : "密码的长度不小于6位",allowBlank : false,minLength : 6},
						          {fieldLabel : '确定密码',name : 'password2',vtype : 'password',initialPassField : 'password',minLengthText : "密码的长度不小于6位",minLength : 6,allowBlank : false}
						          ],
						buttons : [{
							text : '修改',
							iconCls:"icon-edit",
							handler : function() {
								if (!changePasswordForm.getForm().isValid()) {Ext.Msg.alert("提示", "表单校验未通过");return;}
								var formValues = changePasswordForm.getForm().getValues();
								var jsonAll = Ext.encode(formValues);
								changePassword_ajax.request({
											url : Uec3.App.Constants.homeUrl+ '/user/changePassword_submit.do',
											success : function(res) {
												var result = Ext.decode(res.responseText);
												if (result.success == "OK") {Ext.Msg.alert('提示',"修改成功!");} 
												else {Ext.Msg.alert("提示",result.failure);}
										},
											failure : function(res) {Ext.Msg.alert('失败',"网络出现异常，请重先连接");},
											params : {jsonAll : jsonAll}
										});
							}

						}, {text : '关闭',iconCls:"icon-close",handler : function() {changePasswordForm.ownerCt.close();}}
						]
					});
		};

		var controlChangePasswordEvent = function() {
			changePassword_ajax.on('beforerequest', function() {Ext.MessageBox.wait("更新数据中...", "提示");});
			changePassword_ajax.on('requestcomplete', function() {Ext.MessageBox.hide();});
		};

		componentChangePasswordInits();
		
		controlChangePasswordEvent();

		return changePasswordForm;

	},

	/**
	 * Create this modules window here.
	 */
	createWindow : function() {
		var desktop = this.app.getDesktop();
		var win = desktop.getWindow('modifyPassword');
		if (!win) {
			win = desktop.createWindow({
						id : 'modifyPassword',title : '修改密码',
						width : 400,height : 300,iconCls : 'acc-icon',
						shim : true,animCollapse : false,constrainHeader : true,
						resizable : false,maximizable : false,
						collapsible : false,taskbuttonTooltip : "修改密码",layout : "fit",
						tools : [{id : 'refresh',handler : Ext.emptyFn,scope : this}],
						items : [this.getComponents()]
					});
		}
		win.show();
	}
});